#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXN 100
struct S
{
    char* data;
    int top;
    int maxsize;
};
typedef struct S* Stack;
Stack CreateStack(int MaxSize);
void push(Stack S, char c);
char pop(Stack S);
int main()
{
    Stack S;
    S = CreateStack(MAXN);
    int n = 0;
    char c;
    char a[1000];
    while (1)
    {
        gets(a);
        if (strcmp(a, ".") == 0)
        {
            break;
        }
        int n1 = strlen(a);
        for (int i = 0; i < n1; i++)
        {
            if (a[i] == '(')
            {
                push(S, a[i]);
            }
            else if (a[i] == '[')
            {
                push(S, a[i]);
            }
            else if (a[i] == '{')
            {
                push(S, a[i]);
            }
            else if (a[i] == '/' && a[i + 1] == '*')
            {
                push(S, a[i]);
                push(S, a[i + 1]);
                i++;
            }
            else if (a[i] == ')')
            {
                if (S->top == -1)
                {
                    printf("NO\n");
                    printf("?-)");
                    n = 1;
                    break;
                }
                else
                {
                    c = pop(S);
                    if (c != '(')
                    {
                        if (c == '*')
                        {
                            printf("NO\n");
                            printf("/*-?");
                            n = 1;
                            break;
                        }
                        else
                        {
                            printf("NO\n");
                            printf("%c-?", c);
                            n = 1;
                            break;
                        }
                    }
                }
            }
            else if (a[i] == ']')
            {
                if (S->top == -1)
                {
                    printf("NO\n");
                    printf("?-]");
                    n = 1;
                    break;
                }
                else
                {
                    c = pop(S);
                    if (c != '[')
                    {
                        if (c == '*')
                        {
                            printf("NO\n");
                            printf("/*-?");
                            n = 1;
                            break;
                        }
                        else
                        {
                            printf("NO\n");
                            printf("%c-?", c);
                            n = 1;
                            break;
                        }
                    }
                }
            }
            else if (a[i] == '}')
            {
                if (S->top == -1)
                {
                    printf("NO\n");
                    printf("?-}");
                    n = 1;
                    break;
                }
                else
                {
                    c = pop(S);
                    if (c != '{')
                    {
                        if (c == '*')
                        {
                            printf("NO\n");
                            printf("/*-?");
                            n = 1;
                            break;
                        }
                        else
                        {
                            printf("NO\n");
                            printf("%c-?", c);
                            n = 1;
                            break;
                        }
                    }
                }
            }
            else if (a[i] == '*' && a[i + 1] == '/')
            {
                if (S->top == -1)
                {
                    printf("NO\n");
                    printf("?-*/");
                    n = 1;
                    break;
                }
                else
                {
                    c = pop(S);
                    if (c != '*')
                    {
                        printf("NO\n");
                        printf("%c-?", c);
                        n = 1;
                        break;
                    }
                    else
                    {
                        c = pop(S);
                        i++;
                    }
                }
            }
        }
    }
    if (n == 0) {
        if (S->top == -1) { printf("YES\n"); }
        else
        {
            c = pop(S);
            if (c == '*')
            {
                printf("NO\n");
                printf("/*-?");
                n = 1;
            }
            else
            {
                printf("NO\n");
                printf("%c-?", c);
                n = 1;
            }
        }
    }
    return 0;
}
Stack CreateStack(int MaxSize)
{
    Stack S = (Stack)malloc(sizeof(struct S));
    S->data = (char*)malloc(MaxSize * sizeof(char));
    S->top = -1;
    S->maxsize = MAXN;
    return S;
}
void push(Stack S, char c)
{
    S->top++;
    S->data[S->top] = c;
}
char pop(Stack S)
{
    return S->data[S->top--];
}